package com.amado.course08ArrayTwo;

import java.util.Scanner;

public class CrudBegin {

	public static void main(String[] args) {
		//学生数据
		int[][] array = new int[100][4];
		//学生的数量
		int count =0;
		Scanner scanner = new Scanner(System.in);
		
		while (true) {
			System.out.println("\n1、添加 学生2、修改学生 3、删除学生 4、删除学生(根据年龄） 5、插入学生6、排序7、查询");
			int menuvalue = scanner.nextInt();
			switch (menuvalue) {
			case 1:
				System.out.println("请输入学号");
				int addNumber = scanner.nextInt();
				while(true) {
					boolean isNotExist = true;
					//循环查找
					for (int i = 0; i < count; i++) {
						if(array[i][0]==addNumber) {
							isNotExist=false;
							break;
						}
					}
					//不存在，退出学号输入
					if(isNotExist) {
						break;
					}
					//循环输入
					System.out.println("请重新输入学号");
					addNumber = scanner.nextInt();
				}
				System.out.println("请输入姓名");
				int addName = scanner.nextInt();
				System.out.println("请输入性别");
				int addSex = scanner.nextInt();
				while(true) {
					if(addSex==1||addSex==2) {
						break;
					}
					//循环输入
					System.out.println("请重新输入性别");
					addSex = scanner.nextInt();
				}
				System.out.println("请输入年龄");
				int addAge = scanner.nextInt();
				while(true) {
					if(addAge>=18 && addAge<=30) {
						break;
					}
					//循环输入
					System.out.println("请重新输入年龄");
					addAge = scanner.nextInt();
				}
				//学号
				array[count][0]=addNumber;
				//姓名
				array[count][1]=addName;
				//性别
				array[count][2]=addSex;
				//年龄
				array[count][3]=addAge;
				count++;
				System.out.println("添加成功");
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			case 6:
				break;
			case 7:
				System.out.println("学号\t姓名\t性别\t年龄");
				for (int i = 0; i < count; i++) {
					for(int j=0;j<array[i].length;j++) {
						System.out.print(array[i][j]+"\t");
					}
					System.out.println();
				}
				break;
			case 8:
				break;
			default:
				System.out.println("输入的菜单不存在");
			}
		}
	}
}
